package stuman.activity;

import stuman.entity.Section;
import stuman.entity.Student;
import stuman.entity.Subject;
import stuman.util.Container;

import com.StuMan.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class CreateSection extends Activity{

	private Student student;
	private Subject sub;
	
	@Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.create_section_view);
        
        Bundle bun = getIntent().getExtras();
		student = Container.getStudent(bun.getString("student"));
		sub = student.getSubject(bun.getString("subject"));
	}
	
	public void createClick(View view){
		EditText name = (EditText) findViewById(R.id.txtSectionName);
	
		Section sec = new Section(name.getText().toString());
		sub.addSection(sec);
		
		Intent intent = new Intent(CreateSection.this, SectionView.class);
		intent.putExtra("student", student.getFirstName());
		intent.putExtra("subject", sub.getName());
		intent.putExtra("section", sec.getName());
		startActivity(intent);
	}
}
